Skip to content

polarizability for neo#19

Merged
zc62 merged 4 commits intotheorychemyang:masterfrom
Greninja933:polarizability-update
Nov 7, 2025
Merged

polarizability for neo#19
zc62 merged 4 commits intotheorychemyang:masterfrom
Greninja933:polarizability-update

Conversation

@Greninja933
Copy link
Copy Markdown

@Greninja933 Greninja933 commented Oct 19, 2025

Polarizability for NEO, add NEO-HF dipole

Extend e_field.py polarizability to a class Polarizability for both NEO and CNEO.
Add dipole momentum to neo.HF class for polarizability finite different test.

Copy link
Copy Markdown

@zc62 zc62 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments. In addition to these comments, have a look at GitHub CI error messages, especially lint. Linter must pass. You have many trailing whitespaces, which can be easily seen if you run git diff --check before you commit.

Comment thread pyscf/neo/efield.py Outdated
def polarizability(mf):
'polarizability in CNEO'

def polarizability(polobj,with_cphf=True):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add space

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Comment thread pyscf/neo/efield.py Outdated
mo_energy = mf.mo_energy
mo_coeff = mf.mo_coeff
mo_occ = mf.mo_occ
#orbv = mo_coeff[:,~occidx]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete these four lines as they are irrelevant

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think only 54 is irrelevant mo energy coefficient and occ are used later?

Comment thread pyscf/neo/efield.py Outdated
with comp.mol.with_common_orig(charge_center):
int1e_r = comp.mol.intor_symmetric('int1e_r', comp=3)
occidx = mo_occ[t] > 0
mocc = mo_coeff[t][:, occidx]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make name consistent with pyscf prop, this should be orbo

Comment thread pyscf/neo/efield.py Outdated
int1e_r = comp.mol.intor_symmetric('int1e_r', comp=3)
occidx = mo_occ[t] > 0
mocc = mo_coeff[t][:, occidx]
h1[t] = lib.einsum('xuv, ui, vj -> xij', int1e_r, mo_coeff[t], mocc) * comp.charge
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'xuv, ui, vj -> xij' is perhaps from some old code, should be 'xpq,pi,qj->xij' in pyscf prop and in the previous version.

Comment thread pyscf/neo/efield.py Outdated
vind = polobj.gen_vind(mf, mo_coeff, mo_occ)
if with_cphf:
mo1 = cphf.solve(vind, mo_energy, mo_occ, h1, s1,with_f1=with_f1,
max_cycle=polobj.max_cycle_cphf,tol=polobj.conv_tol,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add space between s1,with_f1 and ...,tol=

Comment thread pyscf/neo/efield.py Outdated
_keys = {'efield'}

def __init__(self, mol, *args, **kwargs):
KS.__init__(self, mol, *args, **kwargs)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use super()

Comment thread pyscf/neo/efield.py Outdated
self.stdout = mol.stdout
self._scf = mf

self.with_f1 = True # True for CNEO, False for NEO
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this constant True? Where is the detection?

Comment thread pyscf/neo/efield.py Outdated
self.with_f1 = True # True for CNEO, False for NEO
self.max_cycle_cphf = 100
### default: 1e-5 is already enough
self.conv_tol = 1e-5
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How? pyscf prop uses 1e-9. You need to provide evidence.

Comment thread pyscf/neo/hf.py Outdated
nucl_dip = 0
for t, comp in self.components.items():
if t.startswith('n'):
nucl_dip -= comp.charge * (lib.einsum('xij,ji->x', comp.mol.intor_symmetric('int1e_r', comp=3), dm[t]) - origin)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, read class ComponentSCF in hf.py, fix the case for quantum nuclei, then here can call component.dip_moment, just like electronic part.

Comment thread pyscf/neo/test/test_efield.py Outdated
mf2.scf()
dipole2 = mf2.dip_moment(unit='au')

mf5 = neo.KS(mol,xc='b3lyp')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why mf5 then mf3 then mf4?

@zc62
Copy link
Copy Markdown

zc62 commented Oct 23, 2025

Also need to change the commit message. Learn from existing ones. A short title line, then an empty line, then details. The title line should be <= 50 characters (space included) and details should wrap the line every 72 characters. Your editor of choice should be automatically wrapping the lines for you.

Comment thread pyscf/neo/efield.py Outdated
Comment thread pyscf/neo/efield.py Outdated
@zc62
Copy link
Copy Markdown

zc62 commented Nov 1, 2025

Lint still failed. You perhaps still did not use git diff --check, and your coding tools did not auto trim trailing whitespaces. You need to read the lint error messages and fix all of them.

@zc62 zc62 merged commit ca70700 into theorychemyang:master Nov 7, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants